<?php

class MessageController extends Custom_Controller_RootController
{
	/**
	* 初始化父类
	*/
	public function init()
	{
		
		//根据不同的用户取不同Layout
        $this->view->template='default';
		$this->view->addScriptPath(PROJECT_ROOT.'/application/modules/space/views/scripts/'.$this->view->template.'/');
		
		parent::init();
	}
	
	/**
	 * 信息展示列表
	 */
    public function indexAction() 
    {
    	$messagedata = $this->getMessage();	
    	$this->view->message = $messagedata[0];	
		$this->view->redirecturl= $messagedata[1];
		$this->_helper->layout->disableLayout();
    }
	/**
	 * 设置消息
	 *
	 * @param string $msg
	 */
	protected function setMessage($message)
	{
		$this->_helper->flashMessenger->setNamespace('spacemessage');
		$this->_helper->flashMessenger($message);
		
	}
	
	/**
	 * 取得消息
	 *
	 * @return array
	 */
	protected function getMessage()
	{
		
		$this->_helper->flashMessenger->setNamespace('spacemessage');
		$message = $this->_helper->flashMessenger->getMessages();
		
		return $message;		
	}
	
	
	/**
	 * 
	 * @param string $message
	 * @param string $url
	 */
	protected function showMessage($message, $url ='')
	{
		$this->setMessage($message);		
		$this->setMessage($url);
		$this->_redirect($this->view->urls('index','message','space'));
	}

}